//index.js
//获取应用实例
var app = getApp();
import WxParse from '../../wxParse/wxParse.js';


Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrls: '../images/banner.jpg',
    indicatorDots: true,
    vertical: false,
    autoplay: true,
    interval: 3000,
    duration: 800,
    jieshao: '小胡同、老茶馆、酒吧街、商业区，无限的摩登元素与老北京地道的京味儿相互交融，北京是一座兼具古典风韵与时尚气息的迷人城市。慢一点，灵魂才会跟得上；慢下来，才能感受到城市的脉搏。',
    img1: '../images/1.jpg',
    img2: '../images/2.jpg',
    num: 1,
    fotnum: 1,
    hostUrl: app.globalData.hostUrl,
    showModal:true,  //弹窗是否显示
    countLayerCount:[]  //弹窗内容
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let that = this;
    // if (!wx.getStorageSync('userId')) {
    //   wx.redirectTo({
    //     url: '/pages/login/login',
    //   })
    // }
    this.getBanner();
    this.setData({
      foot: wx.getStorageSync('foot'),
      is_show: wx.getStorageSync('is_show')
    })
    console.log(this.data.is_show)
   
  },
  getBanner: function(typeId) { //读取首页banner
    var that = this;
    wx.request({
      url: app.globalData.apiUrl + 'Index/banner',
      data: {
        // opt: 'getBanner',
        typeId: '',
      },
      header: {
        'content-type': 'application/json'
      },
      success: function(res) {
        // console.log(res)
        if (res.data != null) {
          WxParse.wxParse('jidi', 'html', res.data[1][0].desc, that, 0);
          WxParse.wxParse('fangchan', 'html', res.data[2][3].desc, that, 0);
          WxParse.wxParse('shop', 'html', res.data[3][0].desc, that, 0);
          WxParse.wxParse('fangchan1', 'html', res.data[2][1].desc, that, 0);
          WxParse.wxParse('fangchan2', 'html', res.data[2][2].desc, that, 0);
          WxParse.wxParse('shop1', 'html', res.data[3][1].desc, that, 0);
          WxParse.wxParse('shop2', 'html', res.data[3][2].desc, that, 0);
          // WxParse.wxParse('shop3', 'html', res.data[3][3].desc, that, 0);
          // WxParse.wxParse('shop4', 'html', res.data[3][4].desc, that, 0);

          if (typeId = 1) {
            that.setData({
              imgUrls: res.data,
            })
          } else if (typeId = 2) {
            that.setData({
              imgBanner: res.data,
            })
          }
          
        }
      }
    })
    // console.log(that.data.imgBanner['0'])

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },
  art: function(e) {
    console.log(e)
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  //onShareAppMessage: function () {

  //},
  // 底部导航
  baobei: function() {
    console.log(222)
    wx.reLaunch({
      url: '/pages/baobei/baobei'
    })
  },
  shengji: function() {
    wx.reLaunch({
      url: '/pages/shengji/shengji'
    })
  },
  personal: function() {
    wx.reLaunch({
      url: '/pages/personal/personal'
    })
  },
  goImgXml: function () {
    wx.reLaunch({
      url: '/pages/personal/personal' //接口获取的变量
    })
  }
})